package com.ruoyi.modes.controller;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.modes.entity.TJrProduct;
import com.ruoyi.modes.service.TJrProductService;
import com.ruoyi.system.api.RemoteFileService;
import com.ruoyi.system.api.domain.SysFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


import java.util.List;

@RestController
@RequestMapping("product")
public class TJrProductController {

    @Autowired
    private TJrProductService tJrProductService;

//    @Autowired
//    private RemoteFileService remoteFileService;

    @Autowired
    RemoteFileService remoteFileService;

    @PreAuthorize(hasPermi = "modes:product:list")
    @RequestMapping("list")
    public List<TJrProduct> listAll(){
        List<TJrProduct> tJrProducts = tJrProductService.listAll();
        System.out.println(tJrProducts+"djdkdkdkdkdkd");
        return tJrProducts;
    }

    @PostMapping("uplode")
    public SysFile uplode(MultipartFile file){
        System.out.println("sasasasasasasasasasasasasasasasasasasa");
        return remoteFileService.upload(file).getData();
    }

    @PreAuthorize(hasPermi = "modes:product:list")
    @RequestMapping("list2")
    public List<TJrProduct> listAll2(){
        List<TJrProduct> tJrProducts = tJrProductService.listAll2();
        System.out.println(tJrProducts+"1111111111111111");
        return tJrProducts;
    }

    @PreAuthorize(hasPermi = "modes:product:list")
    @RequestMapping("list3")
    public List<TJrProduct> listAll3(){
        List<TJrProduct> tJrProducts = tJrProductService.listAll3();
        System.out.println(tJrProducts+"4444444444444444");
        return tJrProducts;
    }

    @PreAuthorize(hasPermi = "modes:product:add")
    @RequestMapping("addinstall")
    public boolean addinstall(@RequestBody TJrProduct tJrProduct){
        boolean b = tJrProductService.addinstall(tJrProduct);
        return b;
    }

    @PreAuthorize(hasPermi = "modes:product:update")
    @RequestMapping("updatedeflg")
    public boolean updatedeflg(String id){
        boolean b = tJrProductService.updatedeflg(id);
        return b;
    }

//    @RequestMapping("toupload")
//    public Object toupload(MultipartFile file){
//        System.out.println("++++++++++++++++++++++++++++++++++");
//        R<SysFile> upload = remoteFileService.upload(file);
//        return upload.getData().getUrl();
//    }


}
